package com.compass.mobile.ui.viewModel

import androidx.lifecycle.MutableLiveData
import com.compass.mobile.framework.utils.TipsToast
import com.compass.mobile.models.InspectionReport
import com.compass.mobile.network.callback.IApiErrorCallback
import com.compass.mobile.network.manager.ApiManager
import com.compass.mobile.network.viewmodel.BaseViewModel
import com.google.gson.JsonObject

/**
 * Description： 报告单
 * Date:2024/6/27 14:55
 */
class ReportViewModel : BaseViewModel() {
    val reportListLiveData = MutableLiveData<MutableList<InspectionReport>?>()



    fun geReportList(
        patientId:String?,
        type:String?,
        reportType:String?,
        startDate:Long?,
        endDate: Long?
    ) {
        val params = JsonObject().apply {
            addProperty("patientId", patientId)
            addProperty("type", type)
            addProperty("reportType", reportType)
            addProperty("startDate", startDate)
            addProperty("endDate", endDate)
        }
        launchUIWithResult(responseBlock = {
            ApiManager.api.geReportList(params)
        }, errorCall = object : IApiErrorCallback {
            override fun onError(code: Int?, error: String?) {
                TipsToast.showTips(error)
            }
        }, successBlock = {
            reportListLiveData.value = it
        })
    }
}